function z = my_Obj(v)
  cd('C:\Users\amir\Desktop\optimization_codes')
  load('objmat');
  b=mexcpp(v,S.time,S.needle_num,S.xr);
  q=find(b(:,:,:)<=S.temp);
  [row col I3] = ind2sub(size(b), q);
result1 = inhull([S.X1,S.X2,S.X3],[row+min(S.X1)-S.boundx col+min(S.X2)-S.boundy ...
    I3+min(S.X3)-S.boundz]);
z=sum(S.result-S.result.*result1);
S.count=S.count+1;
end